#include "libraries.h"
#include "extern.h"
#include "furnituregen.h"
#include "lists.h"
#include "Furniture.h"

int FurnitureGen(int endX, int endY)
{
	for (int i = 0; i < endX; i++)
	{
		for (int j = 0; j < endY; j++)
		{
			if (Map[i][j] >= 2)
			{
				int a = 0;
				for (int ii = -1; ii <= 1; ii++)
				{
					for (int jj = -1; jj <= 1; jj++)
					{
						if (Map[i+ii][j+jj] == 0)
						{
							a+=2;
							continue;
						}
						if (Map[i+ii][j+jj] == 1)
						{
							a -= 100;
							continue;
						}
						a++;
					}
				}
				int b = rand() % 190;
				if (b <= a && a != 15)
				{
					CFurniture* p = new CFurniture(i,j,rand() % 2);
					OL.push_front(p);
				}
			}
		}
	}
	return 1;
}